import { Navigate, useRoutes } from 'react-router-dom'

import NotFund from "../components/404";
import List from "../components/List";

import Login from '../pages/Login'
import Main from '../pages/Main'
import About from "../pages/Main/About";
import Home from '../pages/Main/Home'

const routes = [
  {
    path: '/login',
    element: <Login />
  },
  {
    path: '/main',
    element: <Main />,
    children: [
      {
        path: '/main/about',
        element: <About />
      },
      {
        path: '/main/home',
        element: <Home />,
        children: [
          {
            path: '/main/home/list/:id',
            element: <List />
          }
        ]
      }
    ]
  },
  {
    path: '*',
    element: <NotFund />
  },
  {
    path: '/',
    element: <Navigate to='/login' />
  }
]

export default routes

//自定义组件
export const GetRoutes = () => {
  return useRoutes(routes)
}